package com.slz3.business.module.messageManagement.mesSystem.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;

import java.time.LocalDateTime;

public class MesSystemFactory {

    /**
     * 初始化基础属性值
     */
    public static MesSystem initBaseFields(MesSystem mesSystem) {
        if (mesSystem.getUuid() == null) {
            mesSystem.setUuid(UUIDUtils.generateUUID());
            mesSystem.setCreateTime(LocalDateTime.now());
            if (VE.isEmpty(mesSystem.getSerAudit())) {
                mesSystem.setSerAudit(AuditFlag.WAIT_SUBMIT);
            }
            if (VE.isEmpty(mesSystem.getSerUsing())) {
                mesSystem.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            mesSystem.setLastModifyTime(LocalDateTime.now());
        }
        return mesSystem;
    }

    /**
     * 初始化基础属性值
     */
    public static MesSystem initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static MesSystem newTemStyle() {
        return new MesSystem();
    }

}
